//returns number of distinct headers in XML
function getWidthC()
{
	return headerArray.length;
}
//returns number of rows in XML
function getSizeC()
{
	return document.getElementById("size").innerHTML
}
//writes row of XML data determined by path to the id specified.
function XMLtoIDC(path) 
{
	//alters path in XSL document to defined "path"
	elemXPath.setAttribute("select",path);
	
	// code for IE
	if (window.ActiveXObject)
	{
		ex=xml.transformNode(xsl);
		document.getElementById("table").innerHTML=ex;
	}
//	// code for Mozilla, Firefox, Opera, etc.
//	else if (document.implementation && document.implementation.createDocument)
//	{
//		xsltProcessor=new XSLTProcessor();
//		xsltProcessor.importStylesheet(xsl);
//		resultDocument = xsltProcessor.transformToFragment(xml,document);
//		document.getElementById("example").appendChild(resultDocument);
//	}
}

// modies the guncase xsl to include header information.
// adds necessary tags to process the second level tags 
// in the xml file.
function updateXSLHeadersC()
{
	var headers = getXMLHeadersXP();
	var rows = xsl.getElementsByTagName("tr");
	for (var header in headers) 
	{
		// adds <th>header</th> to the first tr element
		var th = xsl.createElement("th");
		th.appendChild(xsl.createTextNode(headers[header]));
		rows[0].appendChild(th)
		
		// add this xml to the XSL file for each type of header.
//		<td>
//			<xsl:for-each select="@header|header">
//				<xsl:value-of select="." />
//				<br />
//			</xsl:for-each>
//		</td>
		// this processes each header node to include all information.
		rows[1].appendChild(xsl.createElement("td"));// root
		var td = rows[1].lastChild;
		
		td.appendChild(xsl.createElement("xsl:for-each"));// child
		var each = td.lastChild;
		each.setAttribute("select", "@" + headers[header] + "|" + headers[header]);
		
		each.appendChild(xsl.createElement("xsl:value-of"));// displays value
		var value = each.lastChild;
		value.setAttribute("select", "." );
		
		each.appendChild(xsl.createElement("br"));// adds in a linen break
		
	}
	// for some reason what has been added here is not recognized while doing transforms
	// reloading the xml doc is a work around for a browser problem known in IE
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async = "false";
	xmlDoc.loadXML(xsl.xml);
	xsl = xmlDoc;
	// since there is a new dom se now set the element that accepts an xpath
	// to help us narrow serches in the document.
	elemXPath=xsl.getElementsByTagName("xsl:apply-templates")[0];
}
